<?php

namespace App\Models;

use Slowlyo\OwlAdmin\Models\BaseModel as Model;


/**
 * 硬件管理
 */
class HardwareList extends Model
{

	protected $table = 'hardware_list';
	protected static function boot()
	{
		parent::boot();

		static::creating(function ($model) {
			$model->created_at = date('Y-m-d H:i:s');
			$model->updated_at = date('Y-m-d H:i:s');
			$model->operator_uid = admin_user()->id;
			$model->editor_uid = admin_user()->id;
		});

		static::updating(function ($model) {
			$model->updated_at = date('Y-m-d H:i:s');
			$model->editor_uid = admin_user()->id;
		});
	}

	/**
     * 获取硬件分类
     */
    public function thecategory()
    {
        return $this->belongsTo(HardwareCategory::class, 'category');
    }
	
	/**
     * 获取硬件位置
     */
    public function location()
    {
        return $this->belongsTo(LocationCategory::class, 'current_location');
    }
}